package com.esri.core.internal.tasks.c;

import com.esri.core.internal.io.handler.h;
import com.esri.core.internal.tasks.TaskListener;
import com.esri.core.internal.tasks.d;
import com.esri.core.io.EsriServiceException;
import com.esri.core.io.UserCredentials;
import com.esri.core.tasks.identify.IdentifyResult;
import java.util.ArrayList;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class a extends d<IdentifyResult[]> {
    private static final long serialVersionUID = 1;

    public a(b bVar, String str, UserCredentials userCredentials, TaskListener<IdentifyResult[]> taskListener) {
        super(bVar, str, userCredentials, taskListener);
        if (bVar == null) {
            throw new EsriServiceException("The identify task requires input parameters");
        }
        bVar.validate();
        setActionInput(bVar);
    }

    public a(b bVar, String str, UserCredentials userCredentials) {
        this(bVar, str, userCredentials, null);
    }

    @Override // com.esri.core.internal.tasks.a
    /* renamed from: a */
    public IdentifyResult[] execute() throws Exception {
        ArrayList arrayList = new ArrayList();
        JsonParser a = h.a(this.serviceURL + "/identify", this.actionInput.generateRequestParams(), getServiceCredentials());
        if (!com.esri.core.internal.util.d.c(a)) {
            throw new EsriServiceException("Unable to parse the Identify result Response.");
        }
        while (a.nextToken() != JsonToken.END_OBJECT) {
            String currentName = a.getCurrentName();
            a.nextToken();
            if ("results".equals(currentName)) {
                while (a.nextToken() != JsonToken.END_ARRAY) {
                    arrayList.add(IdentifyResult.fromJson(a));
                }
            } else {
                a.skipChildren();
            }
        }
        a.close();
        return (IdentifyResult[]) arrayList.toArray(new IdentifyResult[0]);
    }
}
